package com.edoomath.api.web.controller.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.demo2do.core.entity.result.HttpResult;
import com.edoomath.api.servcice.UserService;
import com.edoomath.entity.user.WechatAccount;

/**
 * 
 * @author mohanlan
 *
 */
@Controller
@RequestMapping("/wechat-accounts")
public class WechatAccountController {
    
    @Autowired
    private UserService userService;
    
    /**
     * 
     * @param unionid
     * @return
     */
    @RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public HttpResult loadWechatAccount(@RequestParam(value = "unionid", required = true) String unionid) {
        
        HttpResult httpResult = new HttpResult();
        
        WechatAccount account = userService.loadWechatAccount(unionid);
        
        return httpResult.success()
                         .data("account", account)
                         .message("获取微信用户成功");
    }
    
}
